﻿Imports System.Xml

Public Class slider
    Inherits System.Web.UI.UserControl

    Public objFunction As New FunctionClass
    Public objConfig As New Configs
    Public objAlert As New AlertClass

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            Dim strHTML As New StringBuilder()
            Dim xml As String = ""
            Dim cnt As Integer = 0
            xml = objFunction.ReadEndFile(Server.MapPath("/") & "static/outSite/listfiles/new3.xml")
            Dim rgx As New Regex("\n|\t|\r")
            xml = rgx.Replace(xml, "")
            Dim doc As New XmlDocument()
            doc.LoadXml(xml)
            Dim nodeList As XmlNodeList = doc.GetElementsByTagName("item")
            For Each n As XmlNode In nodeList
                Dim id As String = n.SelectSingleNode("id").InnerText
                Dim title As String = n.SelectSingleNode("title").InnerText
                Dim uri As String = n.SelectSingleNode("uri").InnerText
                Dim image As String = n.SelectSingleNode("image").InnerText
                strHTML.AppendLine("<div class=""slide"">")
                strHTML.AppendLine("    <a href=""/NewDetail.aspx?idNew=" & n.SelectSingleNode("id").InnerText & """ title=""" & title & """ target=""_blank""><img src=""" & image & """ width=""540"" height=""270"" alt=""" & title & """></a>")
                strHTML.AppendLine("    <div class=""caption"" style=""bottom:0"">")
                strHTML.AppendLine("        <p>" & title & "</p>")
                strHTML.AppendLine("    </div>")
                strHTML.AppendLine("</div>")
                cnt = cnt + 1
            Next
            slidesContent.InnerHtml = strHTML.ToString()
            strHTML = Nothing
            doc = Nothing
            nodeList = Nothing
        Catch ex As Exception
            If objConfig.Developer.Equals("1") Then
                objAlert.ErrorBox(Page, "File: " & (New System.Diagnostics.StackTrace).GetFrame(0).GetMethod.DeclaringType.Name & _
                                  " --- Function: " & (New System.Diagnostics.StackTrace).GetFrame(0).GetMethod.Name & _
                                  " --- Mess: " & ex.Message.Replace("'", """"))
            Else
                objAlert.ErrorBox(Page, "Lỗi kỹ thuật, hãy thông báo lại với Admin, xin cảm ơn.")
            End If
        End Try
    End Sub

End Class